package com.cherrypt.api.core.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.cherrypt.api.common.enums.UserLoginEnum;
import com.cherrypt.api.common.exception.TipException;
import com.cherrypt.api.model.dataobject.UserLogin;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author intent
 * @date 2019/7/14 16:30
 * @about <link href='http://zzyitj.xyz/'/>
 */
public interface UserLoginService extends IService<UserLogin> {

    /**
     * 根据id获取Redis中的UserLogin
     *
     * @param uid uid
     * @return
     */
    UserLogin getRedisUserLoginByUid(int uid);

    /**
     * 存储UserLogin
     *
     * @param userLogin
     */
    void saveRedisUserLogin(UserLogin userLogin);

    boolean removeRedisUserLoginByUid(int uid);


    @Transactional
    boolean saveUserLogin(UserLogin userLogin);

    UserLogin getUserLoginByUid(int uid) throws TipException;

    /**
     * 根据email获取用户登录表
     *
     * @param email 邮箱
     * @return
     */
    UserLogin getUserLoginByEmail(String email) throws TipException;

    /**
     * 登录
     *
     * @return
     */
    UserLogin login(String email, String password) throws TipException;

    /**
     * 激活用户
     *
     * @param email
     * @return
     */
    boolean activeUserLogin(String email);

    /**
     * 根据邮箱重置密码
     *
     * @param email
     * @param password
     */
    boolean resetPass(String email, String password) throws TipException;

    boolean updateStatusByUid(int uid, UserLoginEnum userLoginEnum);

    boolean updateStatusByUid(int uid, int code);
}
